package manager.order;

import common.db.*;
import common.main.*;

public class OrderListBean extends MainBean
{
	public void funcExecute() throws Exception
	{
		String sort = (String)inputTable.get("sort");
		String section = (String)inputTable.get("section");
		String word = (String)inputTable.get("word");
		
		String kind = (String)inputTable.get("kind");
		String pway = (String)inputTable.get("pway");
		queryBuffer = new StringBuffer("");
		
		queryBuffer.append("SELECT ");
		queryBuffer.append("CODE, GOODS_CODE, SHOPPER_ID, "); 
		queryBuffer.append("PURCHARSE_VALUE, ORDER_STATE, PAYMENT_WAY, "); 
		queryBuffer.append("DELIVERY_METHOD, OR_DATE, GY_DATE, "); 
		queryBuffer.append("BA_DATE, EN_DATE, COMPLETION_YN, SAVING_POINT, "); 
		queryBuffer.append("REG_ID, TO_CHAR(REG_DATE, 'YYYY-MM-DD') REG_DATE, REG_IP, "); 
		queryBuffer.append("UPD_ID, UPD_DATE, UPD_IP, ");  
		queryBuffer.append("USE_YN, RECEIVER, RECEIVER_PHONE1, RECEIVER_PHONE2, RECEIVER_PHONE3, ");
		queryBuffer.append("EMERGENCY1, EMERGENCY2, EMERGENCY3, ZIPCODE1, ZIPCODE2, ADDR1, ADDR2, ");
		queryBuffer.append("REQUIRE, USE_POINT, BANK_CODE, PURCHARSE_WAY ");
		queryBuffer.append("FROM ORDERLIST WHERE GOODS_CODE LIKE '"+kind+"%' AND PURCHARSE_WAY='"+pway+"' ");
		if(word.length() > 0)
		{
			if(section.equals("TC"))
			{
				queryBuffer.append("AND CODE LIKE '%" + word + "%' ");
			}
			else if(section.equals("TT"))
			{
				queryBuffer.append("AND SHOPPER_ID LIKE '%" + word + "%' ");
			}			
		}
		
		queryBuffer.append("ORDER BY " + sort);

		DBExecute dbe = new DBExecute(queryBuffer.toString());
		outputList = dbe.getDataList();
	}
}